#! /bin/bash



# prepare
ROOT_DIR=$(pwd)

#check file exist
SOURCE_FILE="${ROOT_DIR}/1024.png"
echo $SOURCE_FILE
if [[ ! -e ${SOURCE_FILE} ]]; then
echo "文件不存在"
exit 1
fi
DEST_DIR="${ROOT_DIR}/icon"
#如果目录有图片先清空
if [[ -d ${DEST_DIR} ]]; then
rm -rf dir ${DEST_DIR}
fi
mkdir -p "${DEST_DIR}"
Image_NAME=("20@2x.png" "20@3x.png" "29@2x.png" "29@3x.png" "40@2x.png" "40@3x.png" "60@2x.png" "60@3x.png" "20.png" "29.png" "40.png" "76.png" "76@2x.png" "83.5@2x.png" "1024.png")
Image_SIZE=("40" "60" "58" "87" "80" "120" "120" "180" "20" "29" "40" "76" "152" "167" "1024")


#sips starting
cp "${SOURCE_FILE}" "${DEST_DIR}"
for ((i=0; i<${#Image_SIZE[@]} ;i++)); do
size=${Image_SIZE[i]}
sips -Z ${size} "${SOURCE_FILE}" --out "${DEST_DIR}/${Image_NAME[i]}"
done

作者：mark666
链接：https://www.jianshu.com/p/9254401b5d10
來源：简书
简书著作权归作者所有，任何形式的转载都请联系作者获得授权并注明出处。
